package guanjianzi;

public class TestDriver4 {

        public static void main(String[] args) {



            /**
             * public  static  void  test01(){}
             */
            test01();
            /**
             *  Student stu = test01();//调用封装的类，以访问修饰符的方式
             *   public  static  Student test01(){}
             */

        }
        /**
         * 继承
         */

        public  static  void  test01(){
            //创建子类的实例对象
            Student student = new Student();
            student.doEating();
            System.out.println("--------------------------");

            //创建父类的实例对象
            Person student1 = new Person();
            System.out.println("-------父类指代子类【面向父类的编程】 调用方法---------");
            student1.doEating();
            System.out.println();



            /**
             * 向下塑型，强制转换类
             */
            Person person =  new Person();
            //向下塑型---父类强制转换子类
            Student student2 = (Student)student1;//成功
            //调用子类的扩展方法
            student2.doStuding();
            System.out.println("-----------失败-------------");
            Student student3 = (Student) person;




        }
    }


